package com.lxw.study.behavioral.memento;

public class Client {
    public static void main(String[] args) {
        // 创建发起人
        Originator originator = new Originator();

        // 创建负责人
        Caretaker caretaker = new Caretaker();

        // 设置发起人的状态
        originator.setState1("State 1");
        System.out.println("Current State: " + originator.getState1());

        // 保存状态
        caretaker.saveMemento("第一次备份", originator.createMemento());

        // 修改发起人的状态
        originator.setState1("State 2");
        System.out.println("Updated State: " + originator.getState1());

        // 恢复状态
        originator.restoreMemento(caretaker.getMemento("第一次备份"));
        System.out.println("Restored State: " + originator.getState1());
    }
}
